package com.alibaba.citrus.ots.sales.plan.model.enums;

import com.alibaba.cz.base.model.enterprise.constant.OrganizationTypeEnum;

import java.util.Arrays;

/**
 * @author luyi
 * @date 2021/9/21 10:53 下午
 */
public enum SalesStatBizTypeEnum {
    /**
     * 计划货品汇总维度
     */
    SALESMAN(1,999,"业务员货品汇总"),
    SALES_DEPARTMENT(2,106,"销售部门"),
    SALES_CHANNEL(3,105,"销售渠道"),
    SALES_ORGANIZATION(4,104,"销售组织"),
    BUSINESS_UNIT(5,103,"业务单元");
    /**
     * 维度类型
     */
    private final Integer bizType;

    private final Integer OrganizationType;

    private final String desc;

    SalesStatBizTypeEnum(Integer bizType, Integer organizationType, String desc) {
        this.bizType = bizType;
        this.OrganizationType = organizationType;
        this.desc = desc;
    }

    public Integer getBizType() {
        return bizType;
    }

    public String getDesc() {
        return desc;
    }
    
    public static SalesStatBizTypeEnum get(Integer bizType){
        if (bizType == null){
            return null;
        }
        for (SalesStatBizTypeEnum e: values()) {
            if (bizType.equals(e.getBizType())){
                return e;
            }
        }
        return null;
    }
    public static SalesStatBizTypeEnum getByOrganizationType(Integer organizationType){
        if (organizationType == null){
            return null;
        }
        return Arrays.stream(values()).filter(typeEnum -> typeEnum.getOrganizationType().equals(organizationType)).findAny().orElse(null);
    }

    public Integer getOrganizationType() {
        return OrganizationType;
    }

    public static SalesStatBizTypeEnum match(Integer bizType){
        if (bizType == null){
            return null;
        }
        return Arrays.stream(values()).filter(typeEnum -> typeEnum.getBizType().equals(bizType)).findAny().orElse(null);
    }
}
